package com.track.pulltofersh;

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.CornerPathEffect;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathEffect;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Administrator on 2017/7/28.
 */

public class Arrow extends View {
    public Arrow(Context context) {
        super(context);
    }

    public Arrow(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Arrow(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(21)
    public Arrow(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        Paint paint = new Paint();
        paint.setColor(0xffffffff);
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
        int sw = 6;
        paint.setStrokeWidth(sw);
        paint.setPathEffect(new CornerPathEffect(10));
        int w = getMeasuredWidth();
        int h = getMeasuredHeight();
        Path path1=new Path();
        path1.moveTo((w/2)-(sw/2), (int)(h*0.17f));
        path1.lineTo((w/2)-(sw/2), (int)(h*0.85f));
        path1.close();
        canvas.drawPath(path1, paint);

        Path path2=new Path();
        path2.moveTo((int)(w*0.220f),  (int)(h*0.525f) );
        path2.lineTo((w/2)-(sw/3),  (int)(h*0.83f) );
        path2.close();
        canvas.drawPath(path2, paint);

        Path path3=new Path();
        path3.moveTo((int)(w*0.720f), (int)(h*0.525f));
        path3.lineTo((w/2)-(sw/2), (int)(h*0.83f));
        path3.close();
        canvas.drawPath(path3, paint);
    }
}
